﻿Imports System.Linq
Imports System.Data.Linq

Public Class ConfigRepository
    Private dc As New TanNamChinhDataContext

    Public Sub New()
        dc = GeneralClassDAL.dc
    End Sub

    Public Function SelectAllRecord() As IQueryable(Of tblConfig)
        Dim companies = From p In dc.tblConfigs
                        Select p
        Return companies
    End Function

    Public Function SelectRecordById(ByVal id As Integer) As tblConfig
        Dim company = dc.tblConfigs.SingleOrDefault(Function(p As tblConfig) p.ID_Config = id)
        Return company
    End Function

    Public Sub Insert(ByVal obj As tblConfig)
        dc.tblConfigs.InsertOnSubmit(obj)
        dc.SubmitChanges()
    End Sub

    Public Sub Update(ByVal obj As tblConfig)
        dc.Refresh(RefreshMode.KeepChanges, obj)
        dc.SubmitChanges(ConflictMode.ContinueOnConflict)
    End Sub
End Class
